#include "gameover.h"

void Lose::show(sf::RenderWindow& window, int score, const sf::Vector2f& characterPosition) {
    float parax = characterPosition.x;
    float paray = characterPosition.y;

        sf::RectangleShape grayScreen(sf::Vector2f(1600.0f, 1200.0f));
        grayScreen.setFillColor(sf::Color(0, 0, 0, 150));
        grayScreen.setPosition(characterPosition.x - 800.0, characterPosition.y-600);

        sf::Font font;
        font.loadFromFile("arial.ttf");

        sf::Text loseText("Game Over", font, 100);
        loseText.setFillColor(sf::Color::White);
        loseText.setPosition(parax-100, paray-150);

        sf::Text scoreText("Score: " + std::to_string(score), font, 50);
        scoreText.setFillColor(sf::Color::White);
        scoreText.setPosition(parax-100, paray-25);

        sf::Text menuText("Press ESC to return to menu", font, 40);
        menuText.setFillColor(sf::Color::White);
        menuText.setPosition(parax-100, paray+100);

        while (window.isOpen()) {
            sf::Event event;
            while (window.pollEvent(event)) {
                if (event.type == sf::Event::Closed) {
                    window.close();
                }
                if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Escape) {
                    return;
                }
            }

            window.clear();
            window.draw(grayScreen);
            window.draw(loseText);
            window.draw(scoreText);
            window.draw(menuText);
            window.display();
        }
    }
